<?php
// TuanTM - Get Base Url  (public|web_root directory URL) --> $baseURL
$baseURL = Zend_Controller_Front::getInstance()->getBaseUrl();
?>
<script type="text/javascript" language="javascript" src="<?php echo $baseURL.'/tiny_mce/tiny_mce.js';  ?>"></script>
<script type="text/javascript" language="javascript" src="<?php echo $baseURL.'/js/commonfunctions.js';  ?>"></script>
<script type="text/javascript" language="javascript">
tinyMCE.init({
		// General options
		mode : "textareas",
		theme : "advanced",
		plugins : "pagebreak,style,layer,table,advhr,advimage,advlink,iespell,inlinepopups,insertdatetime,preview,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist",

		// Theme options
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,styleselect,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "justifyleft,justifycenter,justifyright,justifyfull,|,cut,copy,paste,|,bullist,numlist,|,link,unlink,anchor,image,|,insertdate,inserttime,preview,|,forecolor,backcolor",
		theme_advanced_buttons3 : "charmap,emotions,iespell,media,advhr,|,print,code,|,ltr,rtl,|,fullscreen",
		theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_resizing : true,
		// Example content CSS (should be your site CSS)
		// content_css : "css/content.css",

		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",

		// Style formats
		style_formats : [
			{title : 'Bold text', inline : 'b'},
			{title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
			{title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
			{title : 'Example 1', inline : 'span', classes : 'example1'},
			{title : 'Example 2', inline : 'span', classes : 'example2'},
			{title : 'Table styles'},
			{title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
		],

		// Replace values for the template plugin
		template_replace_values : {
			username : "Some User",
			staffid : "991234"
		}
	});
    function standardInput()
    {

        $('#titlepost').val(StandardString($('#titlepost').val()));

        var temp = StandardString(tinyMCE.get('contentpost').getContent());
        tinyMCE.get('contentpost').setContent(temp);

        if($('#titlepost').val().length==0)
        {
            alert("Chưa nhập tên bài viết");
            return false;
        }
        if($(tinyMCE.get('contentpost').getContent()).length==0)
        {
            alert("Chưa nhập nội dung bài viết");
            return false;
        }

        return true;
    }
</script>

<div class="header">
    <h4>
        <a href="<?php echo $baseUrl .'/community' ?>">Cộng đồng</a>
        <span class="separate">&gt;</span>
        <a href="#">Đăng bài mới</a>
    </h4>
</div>
<div class="clear"></div>
<form action="<?php echo $baseURL .'/community/newpost/addpost'; ?>" method="post" enctype="multipart/form-data">
    <table style="border-bottom: 1px #83abc6;border-color: #83abc6">
        <tr>
            <td>
                Tựa đề 
            </td>

            <td>
                <input type="text" id="titlepost" name="titlepost" style="width: 495px"/>
            </td>
        </tr>

        <tr>
            <td>
                Nội dung
            </td>

            <td>
                <textarea width="100%" name="contentpost" id="contentpost">

                </textarea>
            </td>
        </tr>

        <tr>
            <td>
                &nbsp;
            </td>
            <td style="text-align:center;">
                <input type="hidden" id="type" name="type" value="<?php echo $this->type; ?>" />
                <input onclick="return standardInput();" type="submit" value="Đăng bài"
                       style="background: #146EB4;color: white;padding: 5px 7px 5px 7px;font: bolder medium monospace"/>

                <input onclick="javascript: history.go(-1)" type="button" value="Bỏ qua"
                       style="background: #9a9b9a;color: black;padding: 5px 7px 5px 7px;font: bolder medium monospace">
            </td>

        </tr>
    </table>
</form>
    